

import pandas as pd

df = pd.DataFrame({
    'Department': ['HR', 'Tech', 'HR', 'Tech'],
    'Employee': ['Alice', 'Bob', 'Charlie', 'David'],
    'Salary': [5000, 8000, 5500, 8500]
})

# 按部门分组
grouped = df.groupby('Department')
print(grouped.groups)  # 查看分组结构

print(grouped.all())